
// Table 1: Relationship between Gender and Patent Application Outcomes (OLS)

use "${filedata}for_regs.dta", clear 
est clear

foreach i in half_female prop_female all_female {
replace Female=`i'
reghdfe initial_rejection Female ///
inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years ///
, a(art_year) cluster(examiner_year)
	eststo fem_int_`i'
	estadd scalar  clus=e(N_clust) : fem_int_`i'
	sum initial_rejection if e(sample)
	estadd scalar  mean=r(mean)  : fem_int_`i'
	estadd local control="X": fem_int_`i'
	if "`i'"=="half_female" {
	estadd local Fem="Half Female": fem_int_`i'
	} 
	else if "`i'"=="prop_female" {
	estadd local Fem="Proportion": fem_int_`i'
	} 
	else {
	estadd local Fem="All Female": fem_int_`i'
	}

reghdfe patent_issued Female ///
inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years ///
, a(art_year) cluster(examiner_year)
	eststo fem_fin_`i'
	estadd scalar  clus=e(N_clust) : fem_fin_`i'
	sum patent_issued if e(sample)
	estadd scalar  mean=r(mean)  : fem_fin_`i'
	estadd local control="X": fem_fin_`i'
	if "`i'"=="half_female" {
	estadd local Fem="Half Female": fem_fin_`i'
	} 
	else if "`i'"=="prop_female" {
	estadd local Fem="Proportion": fem_fin_`i'
	} 
	else {
	estadd local Fem="All Female": fem_fin_`i'
	}

}

//solo regs
reghdfe initial_rejection Female ///
inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years if solo==1 ///
, a(art_year) cluster(examiner_year)

eststo fem_int_solo
	estadd scalar  clus=e(N_clust) : fem_int_solo
	sum initial_rejection if e(sample)
	estadd scalar  mean=r(mean) : fem_int_solo
	estadd local Fem="Solo": fem_int_solo
	estadd local control="X": fem_int_solo
	
reghdfe patent_issued Female ///
inventor_count prev_apps prev_pats min_years pub_clm_ct pub_wrd_ct pub_wrd_min pub_dep_clm_ct pub_dep_wrd_ct pub_dep_wrd_min pub_wrd_avg pub_dep_wrd_avg  ///  
m_pub_clm_ct m_prev_pats m_min_years if solo==1 ///
, a(art_year) cluster(examiner_year)

eststo fem_fin_solo
	estadd scalar  clus=e(N_clust) : fem_fin_solo
	sum patent_issued if e(sample)
	estadd scalar  mean=r(mean) : fem_fin_solo
	estadd local Fem="Solo": fem_fin_solo
	estadd local control="X": fem_fin_solo
	
 ** No controls
foreach i in half_female prop_female all_female {
replace Female=`i'
reg initial_rejection Female, cluster(examiner_year)
	eststo ncfem_int_`i'
	estadd scalar  clus=e(N_clust) : ncfem_int_`i'
	sum initial_rejection if e(sample)
	estadd scalar  mean=r(mean)  : ncfem_int_`i'
	estadd local control="": ncfem_int_`i'
	if "`i'"=="half_female" {
	estadd local Fem="Half Female": ncfem_int_`i'
	} 
	else if "`i'"=="prop_female" {
	estadd local Fem="Proportion": ncfem_int_`i'
	} 
	else {
	estadd local Fem="All Female": ncfem_int_`i'
	}

reg patent_issued Female, cluster(examiner_year)
	eststo ncfem_fin_`i'
	estadd scalar  clus=e(N_clust) : ncfem_fin_`i'
	sum patent_issued if e(sample)
	estadd scalar  mean=r(mean)  : ncfem_fin_`i'
	estadd local control="": ncfem_fin_`i'
	if "`i'"=="half_female" {
	estadd local Fem="Half Female": ncfem_fin_`i'
	} 
	else if "`i'"=="prop_female" {
	estadd local Fem="Proportion": ncfem_fin_`i'
	} 
	else {
	estadd local Fem="All Female": ncfem_fin_`i'
	}

}

//solo regs
reg initial_rejection Female  if solo==1,  cluster(examiner_year)
eststo ncfem_int_solo
	estadd scalar  clus=e(N_clust) : ncfem_int_solo
	sum initial_rejection if e(sample)
	estadd scalar  mean=r(mean) : ncfem_int_solo
	estadd local Fem="Solo": ncfem_int_solo
	estadd local control="": ncfem_int_solo
reg patent_issued Female if  solo==1, cluster(examiner_year)
eststo ncfem_fin_solo
	estadd scalar  clus=e(N_clust) : ncfem_fin_solo
	sum patent_issued if e(sample)
	estadd scalar  mean=r(mean) : ncfem_fin_solo
	estadd local Fem="Solo": ncfem_fin_solo
	estadd local control="": ncfem_fin_solo
	

esttab   ncfem_int_half_female fem_int_half_female ncfem_int_all_female fem_int_all_female ncfem_int_solo fem_int_solo ncfem_int_prop_female fem_int_prop_female using "${results}motivation.tex" ,replace f se(3) b(3) ///
		drop(_cons) nomtitles posthead("\\ & \multicolumn{8}{c}{Panel A: Initial Rejection}\\ \cmidrule(lr){2-9}") interaction(" $\times$ ")  ///
		stat(mean r2_a , fmt(2 2) labels("Dependent Var. Mean" "Adj. R$^2$")) 	
	
esttab  ncfem_fin_half_female fem_fin_half_female ncfem_fin_all_female fem_fin_all_female ncfem_fin_solo fem_fin_solo ncfem_fin_prop_female fem_fin_prop_female using "${results}motivation.tex" , ///
		drop(_cons) append f se(3) b(3)  nonum  interaction(" $\times$ ")  ///
		 booktabs  nomtitles label star(* 0.10 ** 0.05 *** 0.01) ///
		posthead(" \\ & \multicolumn{8}{c}{Panel B:  Patent Granted}\\ \cmidrule(lr){2-9}") ///
		stat(mean r2_a Fem N clus control, fmt(2 2 0 0 0 0 ) labels("Dependent Var. Mean" "Adj. R$^2$" "Female Definition" "Observations" "\# of Clusters" "Art Unit $\times$ Year")) 	


																
